package com.liudada.cloud.aspect;

import com.liudada.cloud.resp.ResultData;
import com.liudada.cloud.resp.ReturnCodeEnum;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.stereotype.Component;

import java.lang.reflect.Method;

/**
 * @author liushuntao
 * @date 2024/4/18
 */
@Aspect
@Component
public class ControllerAop {

    @Pointcut("execution(* com.liudada.cloud.controller.*.*(..))")
    public void controllerPointCut() {}

    @Around("controllerPointCut()")
    public Object controllerBefore(ProceedingJoinPoint joinPoint) throws Throwable {
        MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
        Method method = methodSignature.getMethod();
        //获取方法名
        String methodName = method.getName();
        //获取参数
        Object[] param = joinPoint.getArgs();
        //开始时间
        long startTime = System.currentTimeMillis();

        Object proceed = joinPoint.proceed();
        //结束时间
        long endTime = System.currentTimeMillis();

        return proceed;
    }

}
